package org.qf.dao.impl;

import org.qf.dao.SmbmsRoleDao;
import org.qf.pojo.SmbmsRole;
import org.qf.utils.BaseDao;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 * @author young
 * @create 2021-01-12-15:03
 * @description
 */
public class SmbmsRoleDaoImpl extends BaseDao implements SmbmsRoleDao {


    //重写dao层接口，查询所有角色信息
    @Override
    public List<SmbmsRole> queryRole() throws Exception {

        List<SmbmsRole> list = new ArrayList<SmbmsRole>();
        String sql = "select * from smbms_role";
        Object[] params = {};
        ResultSet resultSet = executeSQL(sql, params);
        while (resultSet.next()) {
            SmbmsRole smbmsRole = new SmbmsRole();
            smbmsRole.setId(resultSet.getLong("id"));
            smbmsRole.setRoleCode(resultSet.getString("roleCode"));
            smbmsRole.setRoleName(resultSet.getString("roleName"));

            //把对象放在集合中
            list.add(smbmsRole);
        }

        return list;
    }
}
